<?php
/**
 * Created by PhpStorm.
 * User: user
 * Date: 2016/6/2
 * Time: 10:52
 */

use front\assets\AppAsset;
use yii\helpers\Html;

$base = AppAsset::register($this);
$baseUrl = $base->baseUrl;

$this->title = '绑定工号';

$css=<<<Css
.login_job_no{
    background: url({$baseUrl}/img/ico06.png) no-repeat 2px 50% !important;
    background-size: 1rem;
}
Css;
$this->registerCss($css);
?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title><?= Html::encode($this->title)?></title>
    <meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=0" />
    <meta name="format-detection" content="telephone=no,email=no" />
    <meta name="mobileOptimized" content="width" />
    <meta name="handheldFriendly" content="true" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <link rel="stylesheet" href="/static/css/main.css" />
    <script src="/static/script/zepto.min.js"></script>
</head>
<body class="m-login">

<ul>
    <li><input type="text" id="mobile" placeholder="手机号" />
    <li class="login_job_no"><input type="text" id="job_no" placeholder="工号" /></li>
</ul>

<h4><button type="submit" onclick="submit();">绑定</button></h4>

<a class="u-back" href="/web/default/home"><span>回到首页</span></a>

<script>

    function submit()
    {
        var mobile = $.trim($('#mobile').val());
        var job_no = $.trim($('#job_no').val());

        if (mobile == '') {
            msgPopup("请输入手机号码");
            $('#mobile').val('');
            return false;
        }
        if (job_no == '') {
            msgPopup("请输入工号");
            $('#job_no').val('');
            return false;
        }
        var reg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1})|145|147|170|176|177|178)+\d{8})$/;
        if (!reg.test(mobile)) {
            msgPopup("手机号码格式有误，请重新输入");
            $('#mobile').val('');
            return false;
        }

        $.get('', {mobile:mobile, job_no:job_no}, function(data) {
            data = JSON.parse(data);
            if(data.code == 0) {
                window.location.href = '/web/default/home';
            }else {
                msgPopup(data.message);
            }
        })
    }
</script>
</body>
</html>


